<template>
<div class="wrapper">
    <div v-if="web" class="header">
        <text class="header-text">上海卓顾信息科技有限公司</text>
        <div class="back-area" @click="back">
            <image class="back" :src="getUrl('image/back.png')"/>
        </div>
    </div>

    <scroller class="main" :show-scrollbar="false">
        <div class='title'>
            <text class="titleText">余额表</text>
            <text class='button'>下载</text>
        </div>
        
        <div class='group' v-for='(item,index) in balances' :key='index'>
            <div class='item  item-title'>
                <div class='column'>
                    <text class="autoWith">科目编码：</text>
                    <text class="rightBold">{{item.no}}</text>
                </div>
                <div class='column'>
                    <text class="autoWith">科目名称：</text>
                    <text class="rightBold">{{item.text}}</text>
                </div>
            </div>
            <div class='item'>
                <div class='column'>
                    <text class="autoWith">期初余额</text>
                </div>
                <div class='column'>
                    <text class="left">借方：</text>
                    <text class="rightBold">{{item.initjfbalance}}</text>
                </div>
                <div class='column'>
                    <text class="left">贷方：</text>
                    <text class="rightBold">{{item.initdfbalance}}</text>
                </div>
            </div>
            <div class='item'>
                <div class='column'>
                    <text class="autoWith">本期发生额</text>
                </div>
                <div class='column'>
                    <text class="left">借方：</text>
                    <text class="rightBold">{{item.jfbalance}}</text>
                </div>
                <div class='column'>
                    <text class="left">贷方：</text>
                    <text class="rightBold">{{item.dfbalance}}</text>
                </div>
            </div>
            
            <div class='item'>
                <div class='column'>
                    <text class="autoWith">本年累计发生额</text>
                </div>
                <div class='column'>
                    <text class="left">借方：</text>
                    <text class="rightBold">{{item.jfljbalance}}</text>
                </div>
                <div class='column' style='padding-left:20rpx'>
                    <text class="left">贷方：</text>
                    <text class="rightBold">{{item.dfljbalance}}</text>
                </div>
            </div>
            <div class='item'>
                <div class='column'>
                    <text class="autoWith">期末余额</text>
                </div>
                <div class='column'>
                    <text class="left">借方：</text>
                    <text class="rightBold">{{item.endjfbalance}}</text>
                </div>
                <div class='column'>
                    <text class="left">贷方：</text>
                    <text class="rightBold">{{item.enddfbalance}}</text>
                </div>
            </div>
        </div>
    </scroller>
</div>
</template>

<script>
export default {
    data () {
        return {
            web: false,
            balances: [{
                "no": "1001",
                "text": "库存现金",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 256,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 1,
                "pno": null,
                "direction": 1,
                "level": 1,
                "initjfbalance": 1000.00,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 75010.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 185000.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 78010.00,
                "dfljbalance": 187000.00,
                "endjfbalance": 0,
                "endjfbalanceOrg": 0,
                "enddfbalance": 108990.00,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": "1002",
                "text": "银行存款",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 257,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 0,
                "pno": null,
                "direction": 1,
                "level": 1,
                "initjfbalance": 161370.00,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 123.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 128776.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 182523.00,
                "dfljbalance": 149806.00,
                "endjfbalance": 32717.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": "10020001",
                "text": "中行",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 511,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 1,
                "pno": "1002",
                "direction": 1,
                "level": 2,
                "initjfbalance": 161370.00,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 123.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 128776.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 182523.00,
                "dfljbalance": 149806.00,
                "endjfbalance": 32717.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": "1101",
                "text": "短期投资",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 259,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 0,
                "pno": null,
                "direction": 1,
                "level": 1,
                "initjfbalance": 0,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0.00,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 43.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 0.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 43.00,
                "dfljbalance": 0.00,
                "endjfbalance": 43.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": "110103",
                "text": "基金",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 262,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 1,
                "pno": "1101",
                "direction": 1,
                "level": 2,
                "initjfbalance": 0,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0.00,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 43.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 0.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 43.00,
                "dfljbalance": 0.00,
                "endjfbalance": 43.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": "1121",
                "text": "应收票据",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 263,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 1,
                "pno": null,
                "direction": 1,
                "level": 1,
                "initjfbalance": 0,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0.00,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 2.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 0.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 2.00,
                "dfljbalance": 0.00,
                "endjfbalance": 2.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": "1122",
                "text": "应收账款",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 264,
                "assistingAccountId": null,
                "subtypeCode": 1,
                "assistAccountTypeName": null,
                "isAssist": 0,
                "isLeaf": 0,
                "pno": null,
                "direction": 1,
                "level": 1,
                "initjfbalance": 0,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0.00,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 10210.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 12.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 10210.00,
                "dfljbalance": 12.00,
                "endjfbalance": 10198.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": ".0001",
                "text": ".ABC",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 264,
                "assistingAccountId": 30,
                "subtypeCode": 1,
                "assistAccountTypeName": "客户",
                "isAssist": 1,
                "isLeaf": 1,
                "pno": "1122",
                "direction": 1,
                "level": 2,
                "initjfbalance": 0,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0.00,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 10000.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 12.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 10000.00,
                "dfljbalance": 12.00,
                "endjfbalance": 9988.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
                }, {
                "no": ".0004",
                "text": ".dasdad",
                "measuringUnit": null,
                "currSymbol": null,
                "subjectId": 264,
                "assistingAccountId": 42228,
                "subtypeCode": 1,
                "assistAccountTypeName": "客户",
                "isAssist": 1,
                "isLeaf": 1,
                "pno": "1122",
                "direction": 1,
                "level": 2,
                "initjfbalance": 0,
                "initjfbalanceOrg": 0,
                "initdfbalance": 0.00,
                "initdfbalanceOrg": 0.00,
                "initnumber": 0.00,
                "initprice": 0,
                "jfbalance": 210.00,
                "jfbalanceOrg": 0.00,
                "jfnumber": 0.00,
                "dfbalance": 0.00,
                "dfbalanceOrg": 0.00,
                "dfnumber": 0.00,
                "jfljbalance": 210.00,
                "dfljbalance": 0.00,
                "endjfbalance": 210.00,
                "endjfbalanceOrg": 0,
                "enddfbalance": 0,
                "enddfbalanceOrg": 0.00,
                "endnumber": 0.00,
                "endprice": 0
            }]
        }
    },
    created(){
        let platform = weex.config.env.platform;
        this.web = platform.toLowerCase()!=='web'?false:true;
    },
    methods:{
        getUrl(param){
            let bundleUrl = weex.config.bundleUrl; 
            bundleUrl = new String(bundleUrl); 
            let platform = weex.config.env.platform;
            var nativeBase;  
            var native;   

            nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf('/') + 1)
            native = nativeBase.replace('components/','') + 'assets/' + param;
            
            return native;  
        },
        back(){
            var navigator = weex.requireModule('navigator')
            navigator.pop()
        },
        openChild(index){
            this.chartList[index].lock = !this.chartList[index].lock;
        }
    }
    
}
</script>

<style scoped>
.wrapper{
    background-color: #f5f5f5;
}
.header{
    height: 90px;
    width: 750px;
    background-color: #ffffff;
}
.header-text{
    height: 90px;
    line-height: 90px;
    text-align: center;
}
.back-area{
    width: 50px;
    height: 50px;
    position: absolute;
    left: 20px;
    top: 20px;
    align-items: center;
    justify-content: center;
}
.back{
    width: 30px;
    height: 30px;
}
.main{
    flex: 1;
}

.title{
  height:70px;
  background-color: #ffffff;
}
.titleText{
    flex: 1;
    height:70px;
    text-align:center;
    font-size:34px;
    line-height:70px;
    font-weight: bold;
}
.button{
  position: absolute;
  right: 20px;
  top: 8px;
  text-align:center;
  width: 100px;
  height: 54px;
  line-height:54px;
  font-size:28px;
  border-radius: 5px;
  background-color: #94cf28;
  color: #ffffff;
}

.group{
  border-top-width: 2px;
  border-top-color: #dddddd; 
  margin-bottom: 20px;
}

.item{
  height: 70px;
  border-bottom-width: 2px;
  border-bottom-color: #dddddd; 
  background-color: #ffffff;
  flex-direction: row;
  align-items: center;
}
.item-title{
  background-color: #defcfe;
  flex-direction: row;
}
.column{
    flex:1;
    flex-direction: row;
    padding-left:10px; 
    padding-right:10px; 
    align-items: center;
}
.left{
    width: 80px;
    font-size: 26px;
    color: #5c5c5c;
}
.autoWith{
    font-size: 26px;
    color: #5c5c5c;
}
.rightBold{
    flex: 1;
    text-align: right;
    font-size: 26px;
    color: #5c5c5c;
    font-weight: bold;
}
</style>
